package blog.model;

import java.io.Serializable;
import java.util.List;

/**
 * 分页查询类
 */
public class PageData<T> implements Serializable {
  private Integer total;
  private Integer currentPageNum;
  private Integer currentPageSize;
  private List<T> list;
  private Long takeTime;

  public Integer getTotal() {
    return total;
  }

  public void setTotal(Integer total) {
    this.total = total;
  }

  public Integer getCurrentPageNum() {
    return currentPageNum;
  }

  public void setCurrentPageNum(Integer currentPageNum) {
    this.currentPageNum = currentPageNum;
  }

  public Integer getCurrentPageSize() {
    return currentPageSize;
  }

  public void setCurrentPageSize(Integer currentPageSize) {
    this.currentPageSize = currentPageSize;
  }

  public List<T> getList() {
    return list;
  }

  public void setList(List<T> list) {
    this.list = list;
  }

  public Long getTakeTime() {
    return takeTime;
  }

  public void setTakeTime(Long takeTime) {
    this.takeTime = takeTime;
  }

  PageData (PageDataBuilder<T> builder){
    this.total = builder.total;
    this.currentPageNum = builder.currentPageNum;
    this.currentPageSize = builder.currentPageSize;
    this.list = builder.list;
    this.takeTime = builder.takeTime;
  }

  public static <T> PageDataBuilder<T> builder(Class<T> clazz){
    return new PageDataBuilder<T>();
  }

  public static class PageDataBuilder<T> implements Serializable{
    private Integer total;
    private Integer currentPageNum;
    private Integer currentPageSize;
    private List<T> list;
    private Long takeTime;

    PageDataBuilder(){}

    public PageDataBuilder<T> total(Integer total){
      this.total = total;
      return this;
    }

    public PageDataBuilder<T> currentPageNum(Integer currentPageNum){
      this.currentPageNum = currentPageNum;
      return this;
    }

    public PageDataBuilder<T> currentPageSize(Integer currentPageSize){
      this.currentPageSize = currentPageSize;
      return this;
    }

    public PageDataBuilder<T> list(List<T> list){
      this.list = list;
      return this;
    }

    public PageDataBuilder<T> takeTime(Long takeTime){
      this.takeTime = takeTime;
      return this;
    }

    public PageData<T> build(){
      return new PageData<>(this);
    }
  }
}
